<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:t="http://java.sun.com/jsf/composite/tags" xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
	<composite:attribute name="viewName" />

</composite:interface>
<composite:implementation>
	<!--  

<p:scrollPanel style="width:200px;height:200px" autoRefresh="true" >  
<p:panel style="width:400px;height:400px"><p:button></p:button></p:panel>

</p:scrollPanel>
<p:panel style="width:200px;height:200px" >  
<p:scrollPanel >  
<p:panel ><p:button></p:button><p:button></p:button>><p:button></p:button>><p:button></p:button>
<p:button></p:button><p:button></p:button>><p:button></p:button>><p:button></p:button>><p:button></p:button>
<p:button></p:button><p:button></p:button>><p:button></p:button>><p:button></p:button>><p:button></p:button>
<p:button></p:button><p:button></p:button>><p:button></p:button>><p:button></p:button>><p:button></p:button>
<p:button></p:button><p:button></p:button><p:button></p:button><p:button></p:button><p:button>
</p:button><p:button></p:button><p:button></p:button><p:button></p:button><p:button></p:button>
<p:button></p:button><p:button></p:button><p:button></p:button><p:button></p:button><p:button>
<p:button></p:button><p:button></p:button></p:button><p:button></p:button></p:panel>

</p:scrollPanel>
</p:panel>  -->

	<p:panel closable="true" id="complex" style="position:absolute;" header="#{msgs[cc.attrs.viewName]}"  >
	<!-- <p:ajax event="close" onstart="setPanelinVisible('#{cc.attrs.viewName}'); "  update="mainPanel" ></p:ajax> -->
	<p:ajax event="close" onstart="setPanelinVisible('#{cc.attrs.viewName}'); "></p:ajax>
		<p:resizable for="complex" maxHeight="300" maxWidth="400" minHeight="200" minWidth="400" rendered="false"
			onResize="onResize('#{cc.attrs.id}:complex');" />
		<div id="#{cc.attrs.id}:resize"></div>
		<p:draggable for="complex" handle=".ui-panel-titlebar" opacity="0.3" snap="true" snapTolerance="18" snapMode="outer"
			containment="parent" />
		<h:form id="#{cc.attrs.viewName}">
			<ui:include src="/views/#{cc.attrs.viewName}.xhtml" />

		</h:form>
	</p:panel>

	<script>
	function getRes()
	{
		return 'aaaaaaaa';
		}
function setPanelinVisible(viewName)
{
	
	DesktopRemoteBean.setPanelInVisible(viewName,function (){
		location.reload(true);
	/*	delete panels[viewName];		
		delete panelsPreId[viewName];
		
		console.log(panels);
		console.log(panelsPreId);*/
		});
	
	console.log('After setPanel invisible');
}

/*
function setCor()
{
	var divPanel = document.getElementById("#{cc.attrs.id}:complex");
	divPanel.style.height = '200'+ 'px';
	divPanel.style.width = '400px';
	divPanel.style.left = '30px';
	divPanel.style.top = '0px'; 
}*/

function setCoordinates ()
{

DesktopRemoteBean.getPanel('#{cc.attrs.viewName}',function (panel){
	/*console.log(panel);
	console.log(panel.height);
	console.log(panel.x);
	console.log(panel.y);
	console.log(panel.width);*/

	var divPanel = document.getElementById("#{cc.attrs.id}:complex");
	/*console.log(divPanel);
	console.log(divPanel.style);
	console.log(divPanel.style.length);
	console.log(divPanel.style.height);*/
	divPanel.style.height = panel.height + 'px';
	divPanel.style.width = panel.width + 'px';
	divPanel.style.left = panel.x + 'px';
	divPanel.style.top = panel.y + 'px';
	setPanel(panel,"#{cc.attrs.id}:complex");
	
});
}
setCoordinates();

</script>





</composite:implementation>

</html>

